import request from "@/request/request.js"

// 获取设备状态
export function getUserChannelCount(params) {
  return request({
    url: "/dingAppApi/user/getUserChannelCount",
    method: "get",
    params,
  })
}

// 获取设备列表
export function getUserChannelList(params) {
  return request({
    url: "/dingAppApi/user/getUserChannelList",
    method: "get",
    params,
  })
}
// 播放
export function userPlay(params) {
  return request({
    url: "/dingAppApi/user/play",
    method: "get",
    params,
  })
}
// 截图
export function snap(params) {
  const { deviceId, channelId } = params
  return request({
    url: `/api/play/snap`,
    // url: `/api/device/query/snap/${deviceId}/${channelId}`,
    method: "get",
    params,
  })
}
// 视频回放
export function getStart(params) {
  return request({
    url: `/dingAppApi/user/start/${params.channelId}`,
    method: "get",
    params,
  })
}

//查询通道信息
export function getChannelInfo(params) {
  return request({
    url: `/api/common/channel/one`,
    method: "get",
    params,
  })
}

// 云台方向控制
export function gimbalDirectionControl(params) {
  return request({
    url: `/api/common/channel/front-end/ptz`,
    // url: `/api/front-end/ptz/${params.deviceId}/${params.channelId}`,
    method: "get",
    params,
  })
}

// 云台变焦控制
export function gimbalZoomControl(params) {
  return request({
    url: `/api/common/channel/front-end/fi/focus`,
    // url: `/api/front-end/fi/focus/${params.deviceId}/${params.channelId}`,
    method: "get",
    params,
  })
}

// 云台光圈控制
export function gimbalApertureControl(params) {
  return request({
    url: `/api/common/channel/front-end/fi/iris`,
    // url: `/api/front-end/fi/iris/${params.deviceId}/${params.channelId}`,
    method: "get",
    params,
  })
}

// 回放
export function playback(params) {
  return request({
    url: "/api/common/channel/playback",
    method: "get",
    params,
  })
}

// 获取报警列表
export function getMsgList(params) {
  return request({
    url: "/dingAppApi/user/getMsgList",
    method: "get",
    params,
  })
}
// 查看报警视频
export function playByMsgId(params) {
  return request({
    url: "/dingAppApi/user/playByMsgId",
    method: "get",
    params,
  })
}
// 查看报警视频
export function getMsgM3u8Url(params) {
  return request({
    url: "/dingAppApi/user/getMsgM3u8Url",
    method: "get",
    params,
  })
}
export function getM3u8Url(params) {
  return request({
    url: "/dingAppApi/user/getM3u8Url",
    method: "get",
    params,
  })
}
// 查看报警视频
export function customCvrTs(params) {
  return request({
    url: `/customCvrTs/${params.id}`,
    method: "get",
    params: {},
  })
}


// 添加商品收藏
export function addProductFavorite(params) {
  return request({
    url: `/product/favorite/create`,
    method: "post",
    data: params,
    headers: {
      isToken: true,
    },
  })
}

// 取消单个商品收藏
export function cancelProductFavorite(params) {
  return request({
    url: `/product/favorite/delete`,
    method: "post",
    data: params,
    headers: {
      isToken: true,
    },
  })
}
// 获得商品收藏分页
export function getProductFavoritePage(params) {
  return request({
    url: `/product/favorite/page`,
    method: "get",
    params,
  })
}
// 创建订单前计算价格
export function createPreApi(params) {
  return request({
    url: `/trade/order/createPre`,
    method: "post",
    data: params,
    // useToast: false,
    // headers: {
    //   isToken: true,
    // },
  })
}

export function createApi(params) {
  return request({
    url: `/trade/order/create`,
    method: "post",
    data: params,
    useToast: false,
    // headers: {
    //   isToken: true,
    // },
  })
}
